class OrderItem::FactoryOrderMade < OrderItem
  
  validates :furniture_id,
    :presence => true
  
  after_create do |order_item|    
    # feed
    order_item.update_attribute :feed, Feed::OrderItemCreatedAndOrderMade.create!(
      :order_id => order_item.order_id,
      :order_item_id => order_item.id  
    )
  end
  
  scope :being_order_mades, where('order_items.ordered_count > order_items.order_made_count')
  
  def can_be_order_made_count
    ordered_count - order_made_count
  end
end